

ssize_t rio_readlineb(rio_t *rp,void *usrbuf,size_t maxlen)
{
    int n,rc;
    char c,*bufp=usrbuf;

    for(n=1;n<maxlen;n++)
    {
       if((rc=rio_read(rp,&c,1)==1)
       {
         *bufp++=c;
if(c=='\n')
break;
}
else if(rc==0)
{
   if(n==1)
    return 0;
   else
    break;
}
else
return -1;
}
*bufp=0;
return n;
}
